/**
 * SEVAS - Swiss Electronic Vaccination Advisor Service / Agile Development
 *
 * $Id: Application.java 29 2010-08-18 16:51:14Z zimmr7@bfh.ch $
 */
package ch.bfh.sevas;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.jdesktop.beansbinding.Converter;

public class DateConverter extends Converter<Date, String> {

    private static SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");

    public String convertForward(Date arg) {
        return (arg == null) ? "" : dateFormat.format(arg);
    }

    public Date convertReverse(String arg) {
        try {
            return dateFormat.parse(arg);
        } catch (Exception e) {
            return null;
        }
    }

}
